package com.easyhouse.processor;

import com.easyhouse.common.pojo.Product;
import com.easyhouse.mapper.ProductMapper;
import com.easyhouse.utils.DingdingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EasyhouseTaskHandler {
    @Autowired(required = false)
    private ProductMapper productMapper;
    @Autowired
    private DingdingService dingdingService;
    public void runTask(){
        List<Product> products = productMapper.selectProducts();
        double count=0;
        for (Product product : products) {
            count = count+product.getProductPrice();
            //System.out.println(product);
        }
        int allcount=(int)count/10000;
        String text = "房产总价值为："+allcount+"万";
        //System.out.println(text);
        try {
            dingdingService.sent(text);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
